package cn.ffcs.uec.outStaffBatchImportApply.component;

import java.io.FileInputStream;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import lombok.Getter;
import lombok.Setter;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.zkoss.util.media.Media;
import org.zkoss.web.servlet.Servlets;
import org.zkoss.zk.ui.Components;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.IdSpace;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.ForwardEvent;
import org.zkoss.zk.ui.event.UploadEvent;
import org.zkoss.zkplus.databind.BindingListModelList;
import org.zkoss.zul.Div;
import org.zkoss.zul.Filedownload;
import org.zkoss.zul.ListModel;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Window;

import cn.ffcs.raptornuke.plugin.common.zk.util.ZkUtil;
import cn.ffcs.uec.common.vo.UecBdDefdoc;
import cn.ffcs.uec.outStaff.constant.UecOutStaffConstants;
import cn.ffcs.uec.outStaff.model.UecOutStaffInfo;
import cn.ffcs.uec.outStaffBatchImportApply.component.bean.UecOutStaffTalentImportListboxExtBean;
import cn.ffcs.uec.recordsApproval.constant.ApprovalConstants;
import cn.ffcs.uec.recordsApproval.util.ApprovalUtil;
import cn.ffcs.uec.staff.manager.UecTalentTeamManager;
import cn.ffcs.uec.staff.manager.UecTrialManager;
import cn.ffcs.uec.staff.model.UecTalentTeam;
import cn.ffcs.uec.staff.model.UecTrial;
import cn.ffcs.uom.common.constants.BaseUnitConstants;
import cn.ffcs.uom.common.model.DefaultDaoFactory;
import cn.ffcs.uom.common.util.ApplicationContextUtil;
import cn.ffcs.uom.common.util.FileUtil;
import cn.ffcs.uom.common.util.IPortletInfoProvider;
import cn.ffcs.uom.common.util.PlatformUtil;
import cn.ffcs.uom.common.util.StrUtil;
import cn.ffcs.uom.common.vo.PageInfo;
import cn.ffcs.uom.common.zul.PubUtil;

@Controller
@Scope("prototype")
public class UecOutStaffTalentImportListboxExt extends Div implements IdSpace {

	private static final long serialVersionUID = -2829536785151218296L;

	/**
	 * 人员基本信息功能 查询出的实体对象
	 */
	private UecOutStaffInfo uecOutStaffInfo;
	/**
	 * 对应页面上的bean
	 */
	private UecOutStaffTalentImportListboxExtBean bean = new UecOutStaffTalentImportListboxExtBean();

	private UecTrialManager uecTrialManager = (UecTrialManager) ApplicationContextUtil
			.getBean("uecTrialManager");
	/**
	 * 专业人才队伍
	 */
	private UecTalentTeam uecTalentTeam;
	/**
	 * 上传文件
	 */
	private Media media;

	/**
	 * 存放上传数据
	 */
	private List<UecTalentTeam> talentTeams = new ArrayList<UecTalentTeam>();

	private static final int TOTAL_COLUMN = 15;

	private UecTalentTeamManager uecTalentTeamManager = (UecTalentTeamManager) ApplicationContextUtil
			.getBean("uecTalentTeamManager");

	public static final String UEC_OUT_STAFF_TALENT_IMPORT_LISTBOX_EXT_ZUL = "/pages_nmg/outStaffBatchImportApply/comp/uecOutstaffTalentImport_listbox_ext.zul";

	@Getter
	@Setter
	private IPortletInfoProvider portletInfoProvider;

	public UecOutStaffTalentImportListboxExt() {
		Executions.createComponents(
				UEC_OUT_STAFF_TALENT_IMPORT_LISTBOX_EXT_ZUL, this, null);
		Components.wireVariables(this, bean);
		Components.addForwards(this, this, '$');

	}

	/**
	 * 初始化
	 */
	public void onCreate() {
		this.setButtonValid(false, false, false, false, false, false);
		this.setButtonVisible(false, false, false, false);
	}

	/**
	 * 接收事件中的对象outStaffInfo
	 */
	public void onUecOutStaffQueryResponse(ForwardEvent event) {
		uecOutStaffInfo = (UecOutStaffInfo) event.getOrigin().getData();
		if (null != uecOutStaffInfo) {
			uecTalentTeam = new UecTalentTeam();
			if (!StrUtil.isNullOrEmpty(uecOutStaffInfo.getPkPsnMsg())
					&& !StrUtil.isNullOrEmpty(uecOutStaffInfo.getOutStaffId())) {
				uecTalentTeam.setPkPsndoc(uecOutStaffInfo.getPkPsnMsg());
				setButtonValid(true, true, true, false, false, false);
			} else {
				uecTalentTeam.setStaffId(uecOutStaffInfo.getOutStaffId());
				setButtonValid(true, true, true, true, true, true);
			}
			onQueryUecTalentTeam();
		}
	}

	/**
	 * 选择一条记录
	 * 
	 * @throws Exception
	 */
	public void onSelectUecTalentTeamList() throws Exception {
		if (this.bean.getUecOutStaffTalentImportListbox().getSelectedCount() > 0) {
			uecTalentTeam = (UecTalentTeam) bean
					.getUecOutStaffTalentImportListbox().getSelectedItem()
					.getValue();
		}
	}

	/**
	 * 设置按钮 可用
	 * 
	 * @param canAdd
	 * @param candel
	 */
	private void setButtonValid(boolean canDownload, boolean canUpload,
			boolean canView, boolean canAdd, boolean canEdit, boolean candel) {
		this.bean.getViewButton().setDisabled(!canView);
		this.bean.getAddButton().setDisabled(!canAdd);
		this.bean.getEditButton().setDisabled(!canEdit);
		this.bean.getDelButton().setDisabled(!candel);

		this.bean.getDownloadButton().setDisabled(!canDownload);
		this.bean.getUploadButton().setDisabled(!canUpload);
	}

	private void setButtonVisible(boolean canView, boolean canAdd,
			boolean canEdit, boolean candel) {
		this.bean.getViewButton().setVisible(canView);
		this.bean.getAddButton().setVisible(canAdd);
		this.bean.getEditButton().setVisible(canEdit);
		this.bean.getDelButton().setVisible(candel);
	}

	/**
	 * 查询专业人才队伍
	 */
	public void onQueryUecTalentTeam() {
		this.bean.getUecOutStaffTalentImportListboxPaging().setActivePage(0);
		this.onQueryUecTalentTeamList();
	}

	/**
	 * 下载模版
	 */
	@SuppressWarnings("deprecation")
	public void onDownloadTemplate() {
		try {
			String charset = "UTF-8";
			// 服务器文件名
			String fileName = "uecOutStaffTalentTeam_template.xls";
			// 编码后文件名
			String encodedName = null;
			encodedName = URLEncoder.encode(fileName, charset);
			// 将空格替换为+号
			encodedName = encodedName.replace("%20", "+");
			HttpServletRequest httpRequest = (HttpServletRequest) Executions
					.getCurrent().getNativeRequest();
			// 解决ie6 bug 或者是火狐浏览器
			if (encodedName.length() > 150 || Servlets.isGecko(httpRequest)
					|| Servlets.isGecko3(httpRequest)) {
				encodedName = new String(fileName.getBytes(charset),
						"ISO8859-1");
			}
			Filedownload.save(
					new FileInputStream(httpRequest
							.getRealPath("/pages_nmg/uec_outStaff/doc/"
									+ fileName)), "application/octet-stream",
					encodedName);
		} catch (Exception e) {
			ZkUtil.showError("下载员工奖励信息导入模版失败。", "系统提示");
		}
	}

	/**
	 * 文件上传 导入员工
	 * 
	 * @param event
	 * @throws Exception
	 */
	public void onUpload$uploadButton(final ForwardEvent forwardEvent)
			throws Exception {

		// 清除变量
		talentTeams.clear();

		if (null == uecOutStaffInfo || null == uecOutStaffInfo.getOutStaffId()) {
			ZkUtil.showError("未获取人员！", "错误提示");
			return;
		}
		UecTrial qryUecTrial = UecTrial.newInstance();
		qryUecTrial.setStaffId(uecOutStaffInfo.getOutStaffId());
		qryUecTrial.setNmStaffType(BaseUnitConstants.NM_OUT_STAFF_TYPE);
		qryUecTrial = uecTrialManager.findUecTrial(qryUecTrial);
		if (null == qryUecTrial) {
			ZkUtil.showError("此人未入职,请先执行入职操作", "温馨提示");
			return;
		}

		Messagebox.show("确认批量导入文件？导入后将直接发起流程！", "输入确认", Messagebox.OK
				| Messagebox.CANCEL, Messagebox.QUESTION, new EventListener() {
			@Override
			public void onEvent(Event event) throws Exception {
				if (((Integer) event.getData()).intValue() == Messagebox.OK) {
					bean.getUecOutStaffTalentImportListbox().clearSelection();

					media = ((UploadEvent) forwardEvent.getOrigin()).getMedia();
					if (null == media) {
						ZkUtil.showError("请选择要上传的文件!", "系统提示");
						return;
					}
					String fileName = media.getName();
					if (fileName.endsWith(".xls") || fileName.endsWith(".xlsx")) {
						// readsUpLoadFile();
					} else {
						ZkUtil.showError("导入的文件必须是以.xls或.xlsx结尾的EXCEL文件!",
								"系统提示");
						return;
					}
					String[][] objArray = FileUtil.readExcel(media, 1, 1);
					if (objArray == null || objArray.length == 0) {
						ZkUtil.showError("导入文件没有数据！", "错误信息");
						return;
					}
					setDataToRows(objArray, fileName);
				} else {
					return;
				}
			}
		});

	}

	private void setDataToRows(String[][] data, String fileName)
			throws Exception {

		talentTeams.clear();
		String[] row = null;
		boolean isUpload = true;
		for (int i = 0; i < data.length; i++) {
			row = data[i];
			if (row.length < TOTAL_COLUMN) {
				ZkUtil.showError("导入文件数据不全！", "错误信息");
				return;
			}

			UecTalentTeam talentTeam = UecTalentTeam.newInstance();
			for (int j = 0; j < TOTAL_COLUMN; j++) {

				switch (j) {
				// 专业人才名称
				case 0:
					if (null == data[i][j]) {
						ZkUtil.showError("专业人才名称为空！", "错误提示");
						isUpload = false;
						return;
					}
					StringBuilder sBuilder = new StringBuilder(
							" WITH TB_S AS "
									+ " (SELECT T0.MONTH_ID,T0.PK_DEFDOC, T0.NAME, T0.PK_DEFDOCLIST FROM LDAPM_MPW_BD_DEFDOC T0) "
									+ " SELECT "
									+ " DISTINCT "
									+ "  T7.NAME ,"
									+ "  T7.PK_DEFDOC "
									+ "  FROM LDAPM_MPW_HI_PSNDOC_GLBDEF6 JA1 "
									+ "  LEFT JOIN TB_S T7 "
									+ "  ON (JA1.GLBDEF1 = T7.PK_DEFDOC AND JA1.MONTH_ID = T7.MONTH_ID) "
									+ "  where JA1.MONTH_ID = 201805 and T7.NAME = ? ");
					List<Object> params = new ArrayList<Object>();
					params.add(data[i][j]);
					UecBdDefdoc bdDefdoc = DefaultDaoFactory.getDefaultDao()
							.jdbcFindObject(sBuilder.toString(), params,
									UecBdDefdoc.class);
					talentTeam.setGlbdef1(bdDefdoc.getPkDefdoc());
					break;
				// 专业人才等级
				case 1:
					if (null == data[i][j]) {
						ZkUtil.showError("专业人才等级为空！", "错误提示");
						isUpload = false;
						return;
					}
					String glbdef2 = null;
					if ("B级".equals(data[i][j])) {
						glbdef2 = "1001A1100000000006OU";
					}
					if ("C级".equals(data[i][j])) {
						glbdef2 = "1001A1100000000006OT	";
					}
					if ("D级".equals(data[i][j])) {
						glbdef2 = "1001A1100000000006OS";
					}
					talentTeam.setGlbdef2(glbdef2);
					break;
				// 专业工作年度考核结果
				case 2:
					if (null == data[i][j]) {
						ZkUtil.showError("专业工作年度考核结果为空！", "错误提示");
						isUpload = false;
						return;
					}
					String glbdef3 = null;
					if ("称职".equals(data[i][j])) {
						glbdef3 = "1001A11000000000061K";
					}
					if ("优秀".equals(data[i][j])) {
						glbdef3 = "1001A11000000000061J";
					}
					talentTeam.setGlbdef3(glbdef3);
					break;
				// 专家津贴金额
				case 3:
					if (null != data[i][j]) {
						try {
							Long.parseLong(data[i][j]);
						} catch (NumberFormatException e) {
							ZkUtil.showError("专家津贴格式不正确！", "错误提示");
							isUpload = false;
							e.printStackTrace();
							return;
						}
					}
					talentTeam.setGlbdef4(data[i][j]);
					break;
				// 特殊年金金额
				case 4:
					if (null != data[i][j]) {
						try {
							Long.parseLong(data[i][j]);
						} catch (NumberFormatException e) {
							ZkUtil.showError("特殊年金金额格式不正确！", "错误提示");
							isUpload = false;
							e.printStackTrace();
							return;
						}
					}
					talentTeam.setGlbdef5(data[i][j]);
					break;
				// 股票增值权
				case 5:
					talentTeam.setGlbdef6(data[i][j]);
					break;
				// 开始时间
				case 6:
					if (null == data[i][j]) {
						ZkUtil.showError("开始时间为空！", "错误提示");
						isUpload = false;
						return;
					}
					try {
						new SimpleDateFormat("yyyy-MM-dd").parse(data[i][j]);
					} catch (ParseException e) {
						ZkUtil.showError("开始时间格式不正确！", "错误提示");
						isUpload = false;
						e.printStackTrace();
						return;
					}
					talentTeam.setBegindate(data[i][j]);
					break;
				// 人才类型
				case 7:
					if (null == data[i][j]) {
						ZkUtil.showError("人才类型为空！", "错误提示");
						isUpload = false;
						return;
					}
					if ("实操".equals(data[i][i])) {
						talentTeam.setGlbdef10("1");
					} else {
						talentTeam.setGlbdef10("2");
					}
					break;
				// 第一年考核
				case 8:
					talentTeam.setGlbdef11(data[i][j]);
					break;
				// 第二年考核
				case 9:
					talentTeam.setGlbdef12(data[i][j]);
					break;
				// 聘任状态
				case 10:
					if (null == data[i][j]) {
						ZkUtil.showError("聘任状态为空！", "错误提示");
						isUpload = false;
						return;
					}
					if ("在聘".equals(data[i][i])) {
						talentTeam.setGlbdef13("1001A1100000001SVL1S");
					}
					if ("退出".equals(data[i][i])) {
						talentTeam.setGlbdef13("1001A1100000001SVL1T");
					}
					break;
				// 退出时间
				case 11:
					if (null == data[i][j]) {
						ZkUtil.showError("退出时间为空！", "错误提示");
						isUpload = false;
						return;
					}
					try {
						new SimpleDateFormat("yyyy-MM-dd").parse(data[i][j]);
					} catch (ParseException e) {
						ZkUtil.showError("退出时间格式不正确！", "错误提示");
						isUpload = false;
						e.printStackTrace();
						return;
					}
					talentTeam.setGlbdef14(data[i][j]);
					break;
				// 退出原因
				case 12:
					talentTeam.setGlbdef15(data[i][j]);
					break;
				// 子专业
				case 13:
					if (null == data[i][j]) {
						ZkUtil.showError("子专业为空！", "错误提示");
						isUpload = false;
						return;
					}
					StringBuilder builder = new StringBuilder(
							" WITH TB_S AS "
									+ " (SELECT T0.MONTH_ID,T0.PK_DEFDOC, T0.NAME, T0.PK_DEFDOCLIST FROM LDAPM_MPW_BD_DEFDOC T0) "
									+ " SELECT "
									+ " DISTINCT "
									+ "  T7.NAME ,"
									+ "  T7.PK_DEFDOC "
									+ "  FROM LDAPM_MPW_HI_PSNDOC_GLBDEF6 JA1 "
									+ "  LEFT JOIN TB_S T7 "
									+ "  ON (JA1.GLBDEF9 = T7.PK_DEFDOC AND JA1.MONTH_ID = T7.MONTH_ID) "
									+ "  where JA1.MONTH_ID = 201805 and T7.NAME = ? ");
					params = new ArrayList<Object>();
					params.add(data[i][j]);
					bdDefdoc = DefaultDaoFactory.getDefaultDao()
							.jdbcFindObject(builder.toString(), params,
									UecBdDefdoc.class);
					talentTeam.setGlbdef9(bdDefdoc.getPkDefdoc());
					break;
				// 是否生效
				case 14:
					if (null == data[i][j]) {
						ZkUtil.showError("是否生效为空！", "错误提示");
						isUpload = false;
						return;
					}
					if ("是".equals(data[i][j])) {
						talentTeam.setGlbdef8("Y");
					}
					if ("否".equals(data[i][j])) {
						talentTeam.setGlbdef8("N");
					}
					break;
				default:
					break;
				}

			}
			if (!isUpload) {
				return;
			}

			talentTeam.setStaffId(uecOutStaffInfo.getOutStaffId());
			if (StrUtil.isNullOrEmpty(PlatformUtil.getCurrentUser())) {
				ZkUtil.showError("当前用户不存在！", "错误提示");
				return;
			}
			talentTeam
					.setCreator(PlatformUtil.getCurrentUser().getScreenName());
			talentTeam.setCreationtime(new SimpleDateFormat(
					"yyyy-MM-dd HH:mm:ss").format(new Date()));

			talentTeam.setDr(0L);
			talentTeam.setLastflag("Y");

			talentTeam.setNmStaffType(BaseUnitConstants.NM_OUT_STAFF_TYPE);

			talentTeams.add(uecTalentTeam);
		}

		if (null != talentTeams) {
			ListModel list = new BindingListModelList(talentTeams, true);
			this.bean.getUecOutStaffTalentImportListbox().setModel(list);
			this.bean.getUecOutStaffTalentImportListboxPaging().setTotalSize(
					talentTeams.size());

			for (UecTalentTeam talentTeam : talentTeams) {

				// 发起流程 uec_talent_team 新增一条记录
				// 判断该人员是否在审状态，如果是在审状态不允许再次发起此流程
				boolean isOnApproval = ApprovalUtil.isOnApproval(
						ApprovalConstants.OUT_STAFF_TALENT_TEAM_PROC_DEF_ID,
						uecOutStaffInfo.getOutStaffId());
				if (isOnApproval) {
					ZkUtil.showError("在审状态不允许发起！", "错误提示");
					return;
				}

				Long outStaffIdHis = uecOutStaffInfo.getOutStaffId();
				Long outStaffId = outStaffIdHis;
				talentTeam.addStatusCdIS3();
				Long talentTeamId = talentTeam.getTalentTeamId();

				if (StrUtil.isNullOrEmpty(PlatformUtil.getCurrentUser())) {
					ZkUtil.showError("当前登录用户不存在!", "错误提示");
					return;
				}
				String currentName = PlatformUtil.getCurrentUser()
						.getScreenName();

				String startFlowJson = "{" + "formTheme: '盟市外包人员专业人才申请流程',"
						+ " formContent: '专业人才人员:"
						+ uecOutStaffInfo.getPsnName() + "'," + " procDefId: '"
						+ ApprovalConstants.OUT_STAFF_TALENT_TEAM_PROC_DEF_ID
						+ "'," + " urgent: '1'," + " atiActCategoryId: '21',"
						+ " procDefKey: '"
						+ ApprovalUtil.OUT_STAFF_TALENT_TEAM_EDIT + "',"
						+ " formSender: '" + currentName + "',"
						+ " primaryId: '{" + "uec_out_staff_info_his:"
						+ outStaffIdHis + ",uec_out_staff_info:" + outStaffId
						+ ",uec_talent_team:" + talentTeamId + "'}";

				String procInstId = ApprovalUtil.startApproval(startFlowJson);

				if (StrUtil.isNullOrEmpty(procInstId)) {
					ZkUtil.showError("流程发起失败！", "错误提示");
					return;
				}
				// 第一审批人如果是发起人直接到人力审批环节
				ApprovalUtil.isCurrentAssignNames(procInstId);

			}
		}

		ZkUtil.showInformation("专业人才队伍申请流程批量发起", "温馨提示");
	}

	/**
	 * 查看按钮
	 * 
	 * @throws Exception
	 * @throws InterruptedException
	 */
	public void onViewUecTalentTeam() throws Exception, InterruptedException {
		if (uecTalentTeam != null && null != uecTalentTeam.getId()) {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("opType", "view");
			map.put("uecTalentTeam", uecTalentTeam);
			Window window = (Window) Executions.createComponents(
					UecOutStaffConstants.UEC_OUT_STAFF_TALANTTEAM_EDIT_ZUL,
					this, map);
			window.doModal();
			window.addEventListener("onOK", new EventListener() {
				@Override
				public void onEvent(Event event) throws Exception {
					if (event.getData() != null) {
						//
					}
				}
			});
		} else {
			ZkUtil.showError("请选中要查看的记录", "提示信息");
		}
	}

	/**
	 * 新增按钮
	 * 
	 * @throws Exception
	 * @throws
	 */
	public void onAddUecTalentTeam() throws Exception {
		if (null != uecOutStaffInfo) {
			if (!StrUtil.isNullOrEmpty(uecOutStaffInfo.getPkPsnMsg())
					&& !StrUtil.isNullOrEmpty(uecOutStaffInfo.getOutStaffId())) {
				ZkUtil.showError("集团下发数据，禁止操作！", "温馨提示");
			} else {
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("opType", "add");
				map.put("uecOutStaffInfo", uecOutStaffInfo);
				Window window = (Window) Executions.createComponents(
						UecOutStaffConstants.UEC_OUT_STAFF_TALANTTEAM_EDIT_ZUL,
						this, map);
				window.doModal();
				window.addEventListener("onOK", new EventListener() {
					@Override
					public void onEvent(Event event) throws Exception {
						if (event.getData() != null) {
							// 新增或修改完成后，列表从数据库更新
							uecTalentTeam = (UecTalentTeam) event.getData();
							onQueryUecTalentTeamList();
						}
					}
				});
			}
		}
	}

	/**
	 * 编辑按钮
	 * 
	 * @throws Exception
	 * @throws InterruptedException
	 */
	public void onEditUecTalentTeam() throws Exception, InterruptedException {
		if (uecTalentTeam != null && null != uecTalentTeam.getId()) {
			if (!StrUtil.isNullOrEmpty(uecOutStaffInfo.getPkPsnMsg())
					&& !StrUtil.isNullOrEmpty(uecOutStaffInfo.getOutStaffId())) {
				ZkUtil.showError("集团下发数据，禁止操作！", "温馨提示");
			} else {
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("opType", "edit");
				map.put("uecTalentTeam", uecTalentTeam);
				Window window = (Window) Executions.createComponents(
						UecOutStaffConstants.UEC_OUT_STAFF_TALANTTEAM_EDIT_ZUL,
						this, map);
				window.doModal();
				window.addEventListener("onOK", new EventListener() {
					@Override
					public void onEvent(Event event) throws Exception {
						if (event.getData() != null) {
							// 新增或修改完成后，列表从数据库更新
							uecTalentTeam = (UecTalentTeam) event.getData();
							onQueryUecTalentTeamList();
						}
					}
				});
			}
		} else {
			ZkUtil.showError("请选择要编辑的记录", "提示信息");
			return;
		}
	}

	/**
	 * 删除按钮
	 */
	public void onDelUecTalentTeam() {
		if (this.uecTalentTeam != null && uecOutStaffInfo != null) {
			if (!StrUtil.isNullOrEmpty(uecOutStaffInfo.getPkPsnMsg())
					&& !StrUtil.isNullOrEmpty(uecOutStaffInfo.getOutStaffId())) {
				ZkUtil.showError("集团下发数据，禁止操作！", "温馨提示");
			} else {
				ZkUtil.showQuestion("确定要删除吗?", "提示信息", new EventListener() {
					public void onEvent(Event event) throws Exception {
						Integer result = (Integer) event.getData();
						if (result == Messagebox.OK) {
							uecTalentTeam.removeOnly();
							PubUtil.reDisplayListbox(
									bean.getUecOutStaffTalentImportListbox(),
									uecTalentTeam, "del");
							uecTalentTeam = null;
						}
					}
				});
			}
		} else {
			ZkUtil.showError("请选择你要删除的记录", "提示信息");
			return;
		}
	}

	/**
	 * 翻页
	 */
	public void onUecTalentTeamListboxPaging() {
		this.onQueryUecTalentTeamList();
	}

	/**
	 * 清除变量
	 */
	public void clearVariable() {
		uecTalentTeam = null;
	}

	/**
	 * 查询
	 */
	public void onQueryUecTalentTeamList() {
		if (null != uecTalentTeam) {
			PageInfo pageInfo = uecTalentTeamManager
					.queryPageInfoByUecTalentTeam(uecTalentTeam, this.bean
							.getUecOutStaffTalentImportListboxPaging()
							.getActivePage() + 1, this.bean
							.getUecOutStaffTalentImportListboxPaging()
							.getPageSize());
			ListModel list = new BindingListModelList(pageInfo.getDataList(),
					true);
			this.bean.getUecOutStaffTalentImportListbox().setModel(list);
			this.bean.getUecOutStaffTalentImportListboxPaging().setTotalSize(
					pageInfo.getTotalCount());
		}
	}

}
